package com.zhaoyizhe.demo.config;

import com.zhaoyizhe.demo.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
//@ResponseBody
//@ControllerAdvice
@RestControllerAdvice
public class ErrorAdvice {
    @ExceptionHandler
    public Result handler(Exception e) {
        log.error("发生异常 error:",e);
        return Result.fail("发生异常 : " + e.getMessage());
    }
}
